import request from "@/util/http";

// 获取用户列表
export function getUsers() {
  return request({
    url: '/admin/user',
    method: 'get',
    headers: {
      'Content-Type': 'application/json',
      'token': localStorage.getItem('token')
    },
  });
}
export const getUserById = (id) => {
  return request({
    url: `/api/user/${id}`,
    method: 'get',
    headers: {
      'Content-Type': 'application/json',
      'token': localStorage.getItem('token')
    },
  });
};

// 添加用户
export function addUser(data) {
  return request({
    url: '/admin/user',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'application/json',
      'token': localStorage.getItem('token')
    },
  });
}

// 更新用户
export function updateUser(data) {
  return request({
    url: `/admin/user`,
    method: 'put',
    data,
    headers: {
      'Content-Type': 'application/json',
      'token': localStorage.getItem('token')
    },
  });
}

// 删除用户
export function deleteUser(data) {
  return request({
    url: `/admin/user`,
    method: 'delete',
    data,
    headers: {
      'Content-Type': 'application/json',
      'token': localStorage.getItem('token')
    },
  });
}